package dto

import (
	"time"

	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type SysDeviceGetPageReq struct {
	dto.Pagination `search:"-"`
	Name           string `form:"name"  search:"type:contains;column:name;table:sys_device"`
	DeviceId       string `form:"deviceId"  search:"type:contains;column:device_id;table:sys_device"`
	DeptId         int    `form:"deptId"  search:"type:exact;column:dept_id;table:sys_device"`
	Status         int    `form:"status"  search:"type:exact;column:status;table:sys_device"`
	IsBand         int    `form:"isBand" search:""`
}

func (m *SysDeviceGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type SysDeviceInsertReq struct {
	Id           int       `json:"-" comment:"自增主键ID"` // 自增主键ID
	Name         string    `json:"name" comment:"设备名称"`
	DeviceId     string    `json:"deviceId" comment:"设备ID"`
	DeptId       int       `json:"deptId" comment:"所属部门"`
	Manufacturer string    `json:"manufacturer" comment:"厂家"`
	DeviceType   string    `json:"deviceType" comment:"设备类型"`
	Firmware     string    `json:"firmware" comment:"固件版本"`
	DeviceModel  string    `json:"deviceModel" comment:"设备型号"`
	ActiveAt     time.Time `json:"activeAt" comment:"活跃时间"`
	common.ControlBy
}

func (s *SysDeviceInsertReq) Generate(model *models.SysDevice) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.DeviceId = s.DeviceId
	model.DeptId = s.DeptId
	model.Manufacturer = s.Manufacturer
	model.DeviceType = s.DeviceType
	model.Firmware = s.Firmware
	model.DeviceModel = s.DeviceModel
	model.ActiveAt = s.ActiveAt
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *SysDeviceInsertReq) GetId() interface{} {
	return s.Id
}

type SysDeviceUpdateReq struct {
	Id     int    `uri:"id" comment:"自增主键ID"` // 自增主键ID
	Name   string `json:"name" comment:"设备名称"`
	DeptId int    `json:"deptId" comment:"所属部门"`
	common.ControlBy
}

func (s *SysDeviceUpdateReq) Generate(model *models.SysDevice) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.Name = s.Name
	model.DeptId = s.DeptId
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *SysDeviceUpdateReq) GetId() interface{} {
	return s.Id
}

// SysDeviceGetReq 功能获取请求参数
type SysDeviceGetReq struct {
	Id int `uri:"id"`
}

func (s *SysDeviceGetReq) GetId() interface{} {
	return s.Id
}

// SysDeviceDeleteReq 功能删除请求参数
type SysDeviceDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *SysDeviceDeleteReq) GetId() interface{} {
	return s.Ids
}
